home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / X11 / xmcd-1.4 / cda.d / cda.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-10  |  4.3 KB  |  159 lines

  1. /*
  2.  *   cda - Command-line CD Audio Player
  3.  *
  4.  *   Copyright (C) 1995  Ti Kan
  5.  *   E-mail: ti@amb.org
  6.  *
  7.  *   This program is free software; you can redistribute it and/or modify
  8.  *   it under the terms of the GNU General Public License as published by
  9.  *   the Free Software Foundation; either version 2 of the License, or
  10.  *   (at your option) any later version.
  11.  *
  12.  *   This program is distributed in the hope that it will be useful,
  13.  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.  *   GNU General Public License for more details.
  16.  *
  17.  *   You should have received a copy of the GNU General Public License
  18.  *   along with this program; if not, write to the Free Software
  19.  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  *
  21.  */
  22. #ifndef __CDA_H__
  23. #define __CDA_H__
  24.  
  25. #ifndef LINT
  26. static char *_cda_h_ident_ = "@(#)cda.h    5.3 95/01/27";
  27. #endif
  28.  
  29.  
  30. /* Program name string */
  31. #define PROGNAME        "cda"
  32.  
  33.  
  34. /* Copyright message */
  35. #define COPYRIGHT "Copyright (C) 1995 Ti Kan\n\
  36. E-mail: ti@amb.org\n\n\
  37. This is free software and comes with no warranty.\n\
  38. See the GNU General Public License for details.\n"
  39.  
  40.  
  41. /* Memory allocator defines */
  42. #define MEM_ALLOC        malloc
  43. #define MEM_REALLOC        realloc
  44. #define MEM_CALLOC        calloc
  45. #define MEM_FREE        free
  46.  
  47.  
  48. /* CDA packet magic number */
  49. #define CDA_MAGIC        0x1cda
  50.  
  51.  
  52. /* CDA commands */
  53. #define CDA_ON            0x100
  54. #define CDA_OFF            0x101
  55. #define CDA_DISC        0x102
  56. #define CDA_LOCK        0x103
  57. #define CDA_PLAY        0x104
  58. #define CDA_PAUSE        0x105
  59. #define CDA_STOP        0x106
  60. #define CDA_TRACK        0x107
  61. #define CDA_INDEX        0x108
  62. #define CDA_VOLUME        0x109
  63. #define CDA_BALANCE        0x10a
  64. #define CDA_ROUTE        0x10b
  65. #define CDA_PROGRAM        0x10c
  66. #define CDA_SHUFFLE        0x10d
  67. #define CDA_REPEAT        0x10e
  68. #define CDA_STATUS        0x10f
  69. #define CDA_TOC            0x110
  70. #define CDA_EXTINFO        0x111
  71. #define CDA_DEVICE        0x112
  72. #define CDA_VERSION        0x113
  73.  
  74.  
  75. /* CDA return code */
  76. #define CDA_UNKNOWN        0x00
  77. #define CDA_OK            0x01
  78. #define CDA_INVALID        0x02
  79. #define CDA_PARMERR        0x03
  80. #define CDA_FAILED        0x04
  81.  
  82.  
  83. /* Max number of 32-bit arguments */
  84. #define CDA_NARGS        101
  85.  
  86.  
  87. /* CDA_STAT return argument macros */
  88. #define RD_ARG_MODE(x)        (((x) & 0xff000000) >> 24)    /* arg[0] */
  89.  
  90. #define RD_ARG_LOCK(x)        ((x) & 0x00010000)        /* arg[0] */
  91. #define RD_ARG_SHUF(x)        ((x) & 0x00020000)        /* arg[0] */
  92. #define RD_ARG_PROG(x)        ((x) & 0x00040000)        /* arg[0] */
  93. #define RD_ARG_REPT(x)        ((x) & 0x00080000)        /* arg[0] */
  94.  
  95. #define RD_ARG_SEC(x)        ((x) & 0xff)            /* arg[1] */
  96. #define RD_ARG_MIN(x)        (((x) >> 8) & 0xff)        /* arg[1] */
  97. #define RD_ARG_IDX(x)        (((x) >> 16) & 0xff)        /* arg[1] */
  98. #define RD_ARG_TRK(x)        (((x) >> 24) & 0xff)        /* arg[1] */
  99.  
  100. #define WR_ARG_MODE(x,v)    ((x) |= (((v) & 0xff) << 24))    /* arg[0] */
  101.  
  102. #define WR_ARG_LOCK(x)        ((x) |= 0x00010000)        /* arg[0] */
  103. #define WR_ARG_SHUF(x)        ((x) |= 0x00020000)        /* arg[0] */
  104. #define WR_ARG_PROG(x)        ((x) |= 0x00040000)        /* arg[0] */
  105. #define WR_ARG_REPT(x)        ((x) |= 0x00080000)        /* arg[0] */
  106.  
  107. #define WR_ARG_SEC(x,v)        ((x) |= ((v) & 0xff))        /* arg[1] */
  108. #define WR_ARG_MIN(x,v)        ((x) |= (((v) & 0xff) << 8))    /* arg[1] */
  109. #define WR_ARG_IDX(x,v)        ((x) |= (((v) & 0xff) << 16))    /* arg[1] */
  110. #define WR_ARG_TRK(x,v)        ((x) |= (((v) & 0xff) << 24))    /* arg[1] */
  111.  
  112.  
  113. /* CDA_TOC return argument macros */
  114. #define RD_ARG_TOC(x,t,p,m,s)    {    \
  115.     (p) = (bool_t) ((x) >> 24);    \
  116.     ((t) = ((x) >> 16) & 0xff);    \
  117.     ((m) = ((x) >> 8) & 0xff);    \
  118.     ((s) = (x) & 0xff);        \
  119. }                                /* arg[n] */
  120.  
  121. #define WR_ARG_TOC(x,t,p,m,s)    {    \
  122.     if ((p) == (t))            \
  123.         (x) |= 1 << 24;        \
  124.     (x) |= (((t) & 0xff) << 16);    \
  125.     (x) |= (((m) & 0xff) << 8);    \
  126.     (x) |= ((s) & 0xff);        \
  127. }                                /* arg[n] */
  128.  
  129.  
  130. /* CD database information */
  131. typedef struct database {
  132.     word32_t    discid;            /* Magic disc ID */
  133.     char        category[STR_BUF_SZ];    /* CD category */
  134.     char        *dtitle;        /* Disc title */
  135.     char        *trklist[MAXTRACK];    /* Track title list */
  136.     char        *extd;            /* Extended disc info */
  137.     char        *extt[MAXTRACK];    /* Extended track info */
  138.     char        *playorder;        /* Track play order */
  139. } database_t;
  140.  
  141.  
  142. /* CDA pipe protocol packet */
  143. typedef struct cda_pkt {
  144.     word32_t    magic;
  145.     word32_t    pktid;
  146.     word32_t    cmd;
  147.     word32_t    retcode;
  148.     word32_t    arg[CDA_NARGS];
  149. } cdapkt_t;
  150.  
  151.  
  152. /* Public function prototypes */
  153. extern curstat_t    *curstat_addr(void);
  154. extern bool_t        cda_sendcmd(word32_t, word32_t []);
  155. extern bool_t        dbprog_dbload(word32_t);
  156. extern int        cda_daemon(curstat_t *);
  157.  
  158. #endif    /* __CDA_H__ */
  159.